package cn.guetzjb.sys.controller;

import cn.guetzjb.core.entity.R;
import cn.guetzjb.core.utils.UploadUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
@Tag(name = "上传类")
public class UploadController {

    @PostMapping("/server")
    @Operation(summary = "上传到服务器")
    public R uploadToServer(MultipartFile file, @RequestParam(required = false, defaultValue = "false") boolean randomName) {
        return R.ok(UploadUtils.uploadToServer(file, randomName));
    }
}
